<?php
function smarty_function_image($params, &$smarty)
{
	$strPath 		= isset($params['path']) ? $params['path'] : '';	
	$strLink 		= isset($params['lnk']) ? $params['lnk'] : '';	
	$strType 		= isset($params['type']) ? $params['type'] : 1;	
	$intSize		= isset($params['size']) ? $params['size'] : 0;		
	$strAlt			= isset($params['alt']) ? $params['alt'] : '';		
	$strAttr		= isset($params['attr']) ? $params['attr'] : '';
	$isFigure		= isset($params['figure']) ? $params['figure'] : 0;
	$intRpath		= isset($params['rpath']) ? $params['rpath'] : 0;
	$strDir			= '';
	$strFullPath	= '';
	if($strPath != '') {
		switch($strType) {			
			case 'education':
				if($intSize == 0) {
					$strDir 		= DIR_EDUCATION_FULL . $strPath;
					$strFullPath	= LINK_IMAGE_EDUCATION_FULL . $strPath;
				} elseif($intSize == 1) {
					$strDir 		= DIR_EDUCATION_THUMB . $strPath;
					$strFullPath	= LINK_IMAGE_EDUCATION_THUMB . $strPath;
				} elseif($intSize == 2) {
					$strDir 		= DIR_EDUCATION_SMALL . $strPath;
					$strFullPath	= LINK_IMAGE_EDUCATION_SMALL . $strPath;
				} else { // auto width - height
				}				
				break;
			case 'share':
				if($intSize == 0) {
					$strDir 		= DIR_SHARE_FULL . $strPath;
					$strFullPath	= LINK_IMAGE_SHARE_FULL . $strPath;
				} elseif($intSize == 1) {
					$strDir 		= DIR_SHARE_THUMB . $strPath;
					$strFullPath	= LINK_IMAGE_SHARE_THUMB . $strPath;
				} elseif($intSize == 2) {
					$strDir 		= DIR_SHARE_SMALL . $strPath;
					$strFullPath	= LINK_IMAGE_SHARE_SMALL . $strPath;
				} else { // auto width - height
				}				
				break;
			case 'event':
				if($intSize == 0) {
					$strDir 		= DIR_EVENT_FULL . $strPath;
					$strFullPath	= LINK_IMAGE_EVENT_FULL . $strPath;
				} elseif($intSize == 1) {
					$strDir 		= DIR_EVENT_THUMB . $strPath;
					$strFullPath	= LINK_IMAGE_EVENT_THUMB . $strPath;
				} elseif($intSize == 2) {
					$strDir 		= DIR_EVENT_SMALL . $strPath;
					$strFullPath	= LINK_IMAGE_EVENT_SMALL . $strPath;
				} else { // auto width - height
				}				
				break;
			case 'product':
				if($intSize == 0) {
					$strDir 		= DIR_PRODUCT_FULL . $strPath;
					$strFullPath	= LINK_IMAGE_PRODUCT_FULL . $strPath;
				} elseif($intSize == 1) {
					$strDir 		= DIR_PRODUCT_THUMB . $strPath;
					$strFullPath	= LINK_IMAGE_PRODUCT_THUMB . $strPath;
				} elseif($intSize == 2) {
					$strDir 		= DIR_PRODUCT_SMALL . $strPath;
					$strFullPath	= LINK_IMAGE_PRODUCT_SMALL . $strPath;
				} else { // auto width - height
				}				
				break;
			default:
				break;
		}
	}
	if(!file_exists($strDir)) {		
		
	} 
	if($intRpath == 0) {
		$smarty->assign('strAttr',			$strAttr);		
		$smarty->assign('strAlt',			$strAlt);
		$smarty->assign('isFigure',			$isFigure);
		$smarty->assign('strFullPath', 		$strFullPath);		
		$smarty->assign('strIlnk', 			$strLink);		
		$smarty->display(ROOT_DIR . '/library/Ecore/Plugins/Tpl/image.tpl');
	} else {
		return $strFullPath;
	}
}
?>
